﻿var equipMentname = null;
var equimentStatus = null;
var description = null;
var saveBtn = null;
var backBtn = null;

$(function(){
    equipMentname = $("#equipmentname");
    equimentStatus = $("#equimentStatus")
    description = $("#description");
    saveBtn = $("#save");
    backBtn = $("#back");

    equipMentname.next().html("*");
    equimentStatus.next().html("*");
    description.next().html("*")
    equipMentname.on("focus",function(){
        validateTip( equipMentname.next(),{"color":"#666666"},"* 确认账户金额",false);
    }).on("blur",function(){

        if( equipMentname.val() != null){
            validateTip( equipMentname.next(),{"color":"green"},imgYes,true);
        }else{
            validateTip( equipMentname.next(),{"color":"red"},imgNo+" 账户金额有误",false);
        }
    });
    equimentStatus.on("focus",function(){
        validateTip(equimentStatus.next(),{"color":"#666666"},"请选择日期",false);
    }).on("blur",function(){
        if(equimentStatus.val() != null){
            validateTip(equimentStatus.next(),{"color":"green"},imgYes,true);
        }else{
            validateTip(equimentStatus.next(),{"color":"red"},imgNo+" 日期格式错误",false);
        }
    });
    description.on("focus",function(){
        validateTip(description.next(),{"color":"#666666"},"请选择日期",false);
    }).on("blur",function(){
        if(description.val() != null){
            validateTip(description.next(),{"color":"green"},imgYes,true);
        }else{
            validateTip(description.next(),{"color":"red"},imgNo+" 日期格式错误",false);
        }
    });
    saveBtn.on("click",function(){
        equipMentname.blur();
        equimentStatus.blur();
        description.blur();
        if(equipMentname.attr("validateStatus") == "true"
            && equimentStatus.attr("validateStatus") == "true"
            && description.attr("validateStatus") == "true"){
            if(confirm("确定提交数据吗？")){
                $("#equipmentForm").submit();
            }
        }
    });

    backBtn.on("click",function(){
        //alert("modify: "+referer);
        if(referer != undefined
            && null != referer
            && "" != referer
            && "null" != referer
            && referer.length > 4){
            window.location.href = referer;
        }else{
            history.back(-1);
        }
    });
});